#!/bin/sh
set -e
update_binfmt() {
  # Check for update-binfmts
  command -v update-binfmts >/dev/null || return 0

  # Setup binfmt_misc
  update-binfmts --import FEX-x86
  update-binfmts --import FEX-x86_64
}

# Install FEXInterpreter hardlink
# Needs to be done before setting up binfmt_misc
ln -f /usr/bin/FEXLoader /usr/bin/FEXInterpreter

if [ $(uname -m) = 'aarch64' ]; then
  update_binfmt
fi
